// ml:run = $bin < input
#include <iostream>
#include <cstring>
#include <string>

using ll = long long;
int const maxn = 10007;
int const mo = 100000007;
int f[maxn][5][3];
std::string s;
int n;

int main()
{
    std::ios_base::sync_with_stdio(false);
    int T; std::cin >> T;
    while (T--) {
        std::cin >> s;
        n = s.size();
        std::memset(f, 0, sizeof(f));
        for (int t = 0; t < 4; t++) {
            int t1 = t & 1, t2 = t >> 1, tt = t1 + t2;
            int r = s[0] - '0' - tt;
            if (r < 0 || r > 2) continue;
            f[1][t][r] = 1;
        }
        for (int i = 2; i <= n; i++) {
            for (int t = 0; t < 4; t++) {
                int t1 = t & 1, t2 = t >> 1, tt = t1 + t2;
                for (int k = 0; k < 4; k++) {
                    int k1 = k & 1, k2 = k >> 1, kk = k1 + k2;
                    int tot = tt + kk;
                    int r = (s[i - 1] - '0') - tot;
                    if (r < 0 || r > 2) continue;
                    f[i][t][r] += f[i - 1][k][tt];
                    if (f[i][t][r] > mo) f[i][t][r] -= mo;
                }
            }
        }

        ll ans = 0;
        for (int t = 0; t < 4; t++)
            ans = (ans + f[n][t][0]) % mo;
        std::cout << ans << "\n";
    }
}

